<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .container {
      width: 400px;
      height: 500px;
      background-color: rgb(221, 219, 219, 0.7);
    }
    .box {
      width: 200px;
      height: 200px;
      position: relative;
      z-index: 0;
      /* 如果z-index为-1,他处在html层叠上下文中，其会显示在当前上下文的块级元素的下面显示 */
      /* z-index: -1;*/
    }
    .box1 {
      background-color: pink;
      /* 
              当z-index值为2时,box1在.box2上面
              其box1的子元素永远在box2上面 
          */
      /* z-index: 2; */
    }
    .box2 {
      background-color: skyblue;
      top: -50px;
      left: 20px;
    }
    .item {
      width: 100px;
      height: 100px;
      position: absolute;
    }
    .item1 {
      background-color: orange;
      top: 100px;
      left: 50px;
      z-index: 22;
    }
    .item2 {
      background-color: chartreuse;
      top: -20px;
      left: 20px;
      z-index: 2;
    }
  </style>
  <body>
    <div class="container">
      <div class="box box1">
        <div class="item item1"></div>
      </div>
      <div class="box box2">
        <div class="item item2"></div>
      </div>
    </div>
  </body>
</html>